package com.zlict.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zlict.common.annotation.Log;
import com.zlict.common.core.controller.BaseController;
import com.zlict.common.core.domain.AjaxResult;
import com.zlict.common.enums.BusinessType;
import com.zlict.admin.domain.RdAssetsPortfolioDetail;
import com.zlict.admin.service.IRdAssetsPortfolioDetailService;
import com.zlict.common.utils.poi.ExcelUtil;
import com.zlict.common.core.page.TableDataInfo;

/**
 * 资产管理-组合资产明细Controller
 * 
 * @author lqh
 * @date 2025-07-04
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/admin/portfolioDetail")
public class RdAssetsPortfolioDetailController extends BaseController
{
    private final IRdAssetsPortfolioDetailService rdAssetsPortfolioDetailService;

    /**
     * 查询资产管理-组合资产明细列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:portfolioDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(RdAssetsPortfolioDetail rdAssetsPortfolioDetail)
    {
        startPage();
        List<RdAssetsPortfolioDetail> list = rdAssetsPortfolioDetailService.selectRdAssetsPortfolioDetailList(rdAssetsPortfolioDetail);
        return getDataTable(list);
    }

    /**
     * 导出资产管理-组合资产明细列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:portfolioDetail:export')")
    @Log(title = "资产管理-组合资产明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RdAssetsPortfolioDetail rdAssetsPortfolioDetail)
    {
        List<RdAssetsPortfolioDetail> list = rdAssetsPortfolioDetailService.selectRdAssetsPortfolioDetailList(rdAssetsPortfolioDetail);
        ExcelUtil<RdAssetsPortfolioDetail> util = new ExcelUtil<RdAssetsPortfolioDetail>(RdAssetsPortfolioDetail.class);
        util.exportExcel(response, list, "资产管理-组合资产明细数据");
    }

    /**
     * 获取资产管理-组合资产明细详细信息
     */
//    @PreAuthorize("@ss.hasPermi('admin:portfolioDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(rdAssetsPortfolioDetailService.selectRdAssetsPortfolioDetailById(id));
    }

    /**
     * 新增资产管理-组合资产明细
     */
//    @PreAuthorize("@ss.hasPermi('admin:portfolioDetail:add')")
    @Log(title = "资产管理-组合资产明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RdAssetsPortfolioDetail rdAssetsPortfolioDetail)
    {
        return toAjax(rdAssetsPortfolioDetailService.insertRdAssetsPortfolioDetail(rdAssetsPortfolioDetail));
    }

    /**
     * 修改资产管理-组合资产明细
     */
//    @PreAuthorize("@ss.hasPermi('admin:portfolioDetail:edit')")
    @Log(title = "资产管理-组合资产明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RdAssetsPortfolioDetail rdAssetsPortfolioDetail)
    {
        return toAjax(rdAssetsPortfolioDetailService.updateRdAssetsPortfolioDetail(rdAssetsPortfolioDetail));
    }

    /**
     * 删除资产管理-组合资产明细
     */
//    @PreAuthorize("@ss.hasPermi('admin:portfolioDetail:remove')")
    @Log(title = "资产管理-组合资产明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rdAssetsPortfolioDetailService.deleteRdAssetsPortfolioDetailByIds(ids));
    }

    /**
     * 批量插入资产管理-组合资产明细信息
     */
//    @PreAuthorize("@ss.hasPermi('admin:portfolioDetail:batchInsert')")
    @Log(title = "资产管理-组合资产明细", businessType = BusinessType.INSERT)
    @PostMapping("/batchInsert")
    public AjaxResult batchInsert(@RequestBody List<RdAssetsPortfolioDetail> rdAssetsPortfolioDetailList){
        return toAjax(rdAssetsPortfolioDetailService.batchInsertRdAssetsPortfolioDetail(rdAssetsPortfolioDetailList));
    }

    /**
     * 批量移除数据
     */
    @Log(title = "资产管理-组合资产明细", businessType = BusinessType.DELETE)
    @PostMapping("/batchRemove")
    public AjaxResult batchRemove(@RequestBody Long[] ids){
        return toAjax(rdAssetsPortfolioDetailService.batchUpdateRemove(ids));
    }

    /**
     * 批量恢复数据
     */
    @Log(title = "资产管理-组合资产明细", businessType = BusinessType.UPDATE)
    @PostMapping("/batchRecover")
    public AjaxResult batchRecover(@RequestBody Long[] ids){
        return toAjax(rdAssetsPortfolioDetailService.batchUpdateRecover(ids));
    }
}
